//
//  TestViewController.m
//  LBPhotoBrowser
//
//  Created by LINAICAI on 2017/8/16.
//  Copyright © 2017年 LINAICAI. All rights reserved.
//

#import "TestViewController.h"
#import "LBPhotoBrowser.h"
@interface TestViewController ()
@property(nonatomic , strong) UIImageView *imageView;
@property(nonatomic , strong) UIImageView *imageView1;
@end

@implementation TestViewController
- (void)loadView{
    [super loadView];
    self.view.backgroundColor = [UIColor whiteColor];
    
    
}
- (void)tapEvent{
    LBPhoto *photo = [[LBPhoto alloc]initWithURLString:@"https://lianj-public.oss-cn-shenzhen.aliyuncs.com/common/201708230942281764532011.jpg"];
//    photo.placeholderImage = self.imageView.image;
    LBPhoto *photo1 = [[LBPhoto alloc]initWithURLString:@"https://timgsa.baidu.com/timg?image&quality=80&size=b9999_10000&sec=1503050583608&di=e11b88ff49cebf5f33bf015aeeabbb50&imgtype=0&src=http%3A%2F%2Fb.hiphotos.baidu.com%2Fzhidao%2Fpic%2Fitem%2F1f178a82b9014a90e7eb9d17ac773912b21bee47.jpg"];
    [LBPhotoBrowser showWithPhotos:@[photo,photo1] selectIndex:0 sourceImageViewClosure:^UIImageView *(NSInteger index) {
        return self.imageView;
    }];
}
- (void)tapEvent1{
    LBPhoto *photo = [[LBPhoto alloc]initWithURLString:@"https://v2ex.assets.uxengine.net/assets/sidebar/udacity_20170822.gif"];
    LBPhoto *photo1 = [[LBPhoto alloc]initWithURLString:@"https://timgsa.baidu.com/timg?image&quality=80&size=b9999_10000&sec=1503050583608&di=e11b88ff49cebf5f33bf015aeeabbb50&imgtype=0&src=http%3A%2F%2Fb.hiphotos.baidu.com%2Fzhidao%2Fpic%2Fitem%2F1f178a82b9014a90e7eb9d17ac773912b21bee47.jpg"];
    LBPhoto *photo2 = [[LBPhoto alloc]initWithURLString:@"https://ss1.baidu.com/6ONXsjip0QIZ8tyhnq/it/u=2259120937,1775090841&fm=173&s=389C7A94CCC9794F3485CDC90300E017&w=550&h=324&img.JPEG"];
    
    [LBPhotoBrowser showWithPhotos:@[photo,photo1,photo2] selectIndex:0 sourceImageViewClosure:^UIImageView *(NSInteger index) {
        return self.imageView1;
    }];
}
- (UIImageView *)imageView{
    if (!_imageView) {
        _imageView = [[UIImageView alloc]initWithImage:[UIImage imageNamed:@"201708230942281764532011.jpg"]];
        _imageView.frame = CGRectMake(0, 64, 100, 100);
        _imageView.userInteractionEnabled = YES;
        [_imageView addGestureRecognizer:[[UITapGestureRecognizer alloc]initWithTarget:self action:@selector(tapEvent)]];
    }
    return _imageView;
}
- (UIImageView *)imageView1{
    if (!_imageView1) {
        _imageView1 = [[UIImageView alloc]initWithImage:[UIImage imageNamed:@"udacity_20170822.gif"]];
        _imageView1.frame = CGRectMake(self.view.bounds.size.width-100, 64, 100, 100);
        _imageView1.userInteractionEnabled = YES;
        [_imageView1 addGestureRecognizer:[[UITapGestureRecognizer alloc]initWithTarget:self action:@selector(tapEvent1)]];
    }
    return _imageView1;
}
- (void)viewDidLoad {
    [super viewDidLoad];
    [self.view addSubview:self.imageView];
    [self.view addSubview:self.imageView1];
 
    // Do any additional setup after loading the view.
}

- (void)didReceiveMemoryWarning {
    [super didReceiveMemoryWarning];
    // Dispose of any resources that can be recreated.
}

/*
#pragma mark - Navigation

// In a storyboard-based application, you will often want to do a little preparation before navigation
- (void)prepareForSegue:(UIStoryboardSegue *)segue sender:(id)sender {
    // Get the new view controller using [segue destinationViewController].
    // Pass the selected object to the new view controller.
}
*/

@end
